﻿<?php
session_start();
$_SESSION['_code']=rand(1,9999);
require('conn.php');
//require('session.php');
require('functions.php');
//print_r($userdata);

//全站访问
if($config['fangwen']==4){
	exit('网站正在更新');
}	
//有效访问时间
if(is_numeric($config['ReadTime'])){
	$readtime=$config['ReadTime']*1000;
}else{
	$readtime=0;
}
$aid=guolv($_GET['aid']);//文章id
$uid=guolv($_GET['uid']);//用户id
$ip=GetIP();

//获取文章信息
if(is_numeric($aid)){
	$row=$mysql->query("select * from `article` where `id` in({$aid}) limit 1");
	if($row){
		$data=$row[0];
		$_pic=str_replace('[weixin]','',$data['pic']);
		// if($data['pv_max']!==0 || $data['pv_max']!=='-1'){
			// if($data['pv']>=$data['pv_max']){
				// exit('文章已过期');	
			// }
		// }


		$顶部广告=$mysql->query("select * from `addata` where `ad_type`='顶部广告' limit 1");//广告
		$底部广告=$mysql->query("select * from `addata` where `ad_type`='底部广告' limit 1");//广告
		$统计代码=$mysql->query("select * from `addata` where `ad_type`='统计代码' limit 1");//广告
		$微信广告=$mysql->query("select * from `addata` where `ad_type`='微信广告' limit 1");//广告
		$悬浮广告=$mysql->query("select * from `addata` where `ad_type`='悬浮广告' limit 1");//广告
	}else{
		exit('文章已过期');	
	}
}else{
	_location($site,301);
	exit;
}

//访问限制
if($config['fangwen']=='2,5'){
		if(is_weixin()==false || is_QQ()==false){
			$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
			echo "<title>{$data['title']}</title>";
			echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
			echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";	
			exit;//仅限微信、QQ访问
		}
}

if($config['fangwen']==1){
	if(is_mobile()==false){
		$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
		echo "<title>{$data['title']}</title>";
		echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
		echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";
		exit;//仅限手机访问
	}
}

if($config['fangwen']==2){
		if(is_weixin()==false){
			$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
			echo "<title>{$data['title']}</title>";
			echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
			echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";
			exit;//仅限微信访问		
		}
}

// setcookie("sdone");
// print_r($_COOKIE);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title><?php echo $data['title']?></title>
<meta name="keywords" content="<?php echo $data['title']?>"/>
<meta name="description" content="<?php echo $data['title']?>"/>
<link rel="stylesheet" type="text/css" href="static/hz.css" media="all">
<div style="height:0;overflow:hidden;"><img src="http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url=<?php echo $_pic?>"></div>
<style type="text/css">
#y-iframe{
	position:fixed;
	_position:absolute;
	left:0;
	bottom:0;
	_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
	z-index:99999;
	padding-top:1px;
	width:100%;
	min-height:81px;
	height:auto;
	_height:81px;
	
}
.iframe-wrap{
	position:relative;
	margin:0 auto;
	width:1003px;
	height:81px;
}
</style>

</head>
<body class="mhome" style="font-family:'STXihei';">
<div class="article">
  <h1><?php echo $data['title']?></h1>
  <p class="art_txt sau"><span>分享累计收益<a href="reg.php?uid=<?php echo $uid?>"><font color=red><?php echo $data['pv']*$data['money']?></font></a>元&nbsp;&nbsp;<?php
					$row_type=$mysql->query("select * from `typedata` where `id`='{$data['type']}' limit 1");
				?>
			  <?php echo ubb($row_type[0]['type_author'])?></span></p>
<div id="tConArt" class="art_co sau">
				<?php 
				if($顶部广告[0]['endtime']!==''){
					if(strtotime($顶部广告[0]['endtime'])>=time()){
						echo $顶部广告[0]['ad_content'];
					}
				}
				?>
				<div class="rich_media_content" id="js_content">
				<!--内容-->
						<div id="neirong">
						<?php echo $data['content']?>
						</div>			
		
				<?php 
				if($底部广告[0]['endtime']!==''){
					if(strtotime($底部广告[0]['endtime'])>=time()){
						echo $底部广告[0]['ad_content'];
					}
				}
				?>	
				</div>


</div>
<script type="text/javascript" src="<?php echo $site?>/static/jquery-1.10.2.min.js" ></script>
<script type="text/javascript" src="<?php echo $site?>/static/detail.js" ></script>
<div id="y-iframe">
		<div class="iframe-wrap">
				<?php 
				if($悬浮广告[0]['endtime']!==''){
					if(strtotime($悬浮广告[0]['endtime'])>=time()){
						echo $悬浮广告[0]['ad_content'];
					}
				}
				?>			
		</div>
</div>
<!-- more -->
<div style="margin:10px auto 0px;width:90%;padding-bottom:5px;border-bottom:1px solid #c8c7cc;font-family:'微软雅黑'" align="center"><a href="list.php?uid=<?php echo $uid?>">更多内容>></a></div>
<div class="list">	<?php 
				if($微信广告[0]['endtime']!==''){
					if(strtotime($微信广告[0]['endtime'])>=time()){
						echo $微信广告[0]['ad_content'];
					}
				}
				?>
<?php
if(is_numeric($config['DetailMoreNum'])==true && $config['DetailMoreNum']>0){
	
if($config['DetailMoreOrder']=='rand'){
	$rows_more=$mysql->query("select * from `article` order by rand() limit 0,{$config['DetailMoreNum']}");
}elseif($config['DetailMoreOrder']=='hot'){
	$rows_more=$mysql->query("select * from `article` order by -`pv` limit 0,{$config['DetailMoreNum']}");
}elseif($config['DetailMoreOrder']=='new'){
	$rows_more=$mysql->query("select * from `article` order by `id` desc limit 0,{$config['DetailMoreNum']}");
}elseif($config['DetailMoreOrder']=='money'){
	$rows_more=$mysql->query("select * from `article` order by -`money` limit 0,{$config['DetailMoreNum']}");
}else{
	$rows_more=$mysql->query("select * from `article` order by -`pv` limit 0,{$config['DetailMoreNum']}");
}	

foreach($rows_more as $v_more){
	$pic1=str_replace('[weixin]','',$v_more['pic']);
print <<<table
		<div class="list_d">
    	<a class="list_dd bor_b" href="{$site}/detail.php?aid={$v_more['id']}&uid={$uid}" target="_blank">
		<div class="list_l"><img src="{$pic1}" width="135" height="90"/></div>
		<div class="list_lt">
			<dl class="list_ld">
				<dt>{$v_more['title']}</dt>
				<dd>阅读量：{$v_more['pv']} <font color=red>  点击分享赚{$v_more['money']}元</font></dd>
			</dl>
		</div>
		</a>
		</div>
table;
}
}
?>
</div>

<script>
var sUserAgent = navigator.userAgent.toLowerCase();
var IsAndroid = sUserAgent.match(/android/i) == "android";
var IsIos = sUserAgent.match(/iphone os/i) == "iphone os";
var _aid = '<?php echo guolv($_GET['aid'])?>';
var _uid = '<?php echo guolv($_GET['uid'])?>';
var _ip = '<?php echo getip()?>';
var _host = document.domain;
var _width = window.screen.width;
var _height= window.screen.height;
var _time=parseInt((new Date).getTime()/1000);
var _referer=document.referrer;
var _useragent=navigator.userAgent;
var _url = window.location.href; 
var _cookie = cookieRead("read");
	
    /*$(function() {
        var pattern = /^http:\/\/mmbiz/;
        var prefix = 'http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url=';
        $("img").each(function(){
            var src = $(this).attr('src');
            if(pattern.test(src)){
                var newsrc = prefix+src;
                $(this).attr('src',newsrc);
            }
			//$('#js_content').autoIMG();
        });
	})*/
	
	function checkCookie(){
		if(window.navigator.cookieEnabled){
			return true;
		}else{
			return false;
		}
	}
	
	
	function count(){
			$.post("<?php echo $site?>/count.php?aid="+_aid+"&uid="+_uid+"&ip="+_ip+"&money=<?php echo $data['money']?>"+"&title=<?php echo $data['title']?>"+"&time="+_time+"&url="+_url+"&width="+_width+"&height="+_height,function(result){
				//alert(result);
				//cookie_set("read",1);
				return false;
				// if(result==0){
					// 
				// }else{
					// return;
				// }
			});
	}
	
	if( _uid!=='' && _aid!==''){
		setTimeout('count()',<?php echo $readtime?>);
	}		



var h = $(window).width();
            $(".iframe-wrap img").css("width", h);
</script>
<?php
if($config['DetailPvOpen']==1){
	echo "<p style='padding-left:27px;'>阅读数：{$data['pv']}</p>";
}elseif($config['DetailPvOpen']==2){
	$rand_pv=rand(111111,999099);
	echo "<p style='padding-left:27px;'>阅读数：{$rand_pv}</p>";
}
?>
<?php 
$mysql->free();
$mysql->close();
?>	<br><br><br><?php 
				if($统计代码[0]['endtime']!==''){
					if(strtotime($统计代码[0]['endtime'])>=time()){
						echo $统计代码[0]['ad_content'];
					}
				}
				?>
</body>
</html>
